
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>动态内存分配 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    
    <link rel="stylesheet" href="../../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-katex/katex.min.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-codeblock-label/block.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-click-reveal/click_reveal.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="part-2.html" />
    
    
    <link rel="prev" href="intro.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../../">
            
                <a href="../../../">
            
                    
                    实验简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../../notes/log.html">
            
                <a href="../../../notes/log.html">
            
                    
                    更新日志
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">实验之前</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../pre-lab/env.html">
            
                <a href="../../pre-lab/env.html">
            
                    
                    环境部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../../pre-lab/gdb.html">
            
                <a href="../../pre-lab/gdb.html">
            
                    
                    GDB 调试方法*
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">实验指导</li>
        
        
    
        <li class="chapter " data-level="3.1" >
            
                <span>
            
                    
                    实验指导零
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../../lab-0/guide/intro.html">
            
                <a href="../../lab-0/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../../lab-0/guide/part-1.html">
            
                <a href="../../lab-0/guide/part-1.html">
            
                    
                    创建项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../../lab-0/guide/part-2.html">
            
                <a href="../../lab-0/guide/part-2.html">
            
                    
                    移除标准库依赖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../../lab-0/guide/part-3.html">
            
                <a href="../../lab-0/guide/part-3.html">
            
                    
                    移除运行时环境依赖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.5" data-path="../../lab-0/guide/part-4.html">
            
                <a href="../../lab-0/guide/part-4.html">
            
                    
                    编译为裸机目标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.6" data-path="../../lab-0/guide/part-5.html">
            
                <a href="../../lab-0/guide/part-5.html">
            
                    
                    生成内核镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.7" data-path="../../lab-0/guide/part-6.html">
            
                <a href="../../lab-0/guide/part-6.html">
            
                    
                    调整内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.8" data-path="../../lab-0/guide/part-7.html">
            
                <a href="../../lab-0/guide/part-7.html">
            
                    
                    重写程序入口点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.9" data-path="../../lab-0/guide/part-8.html">
            
                <a href="../../lab-0/guide/part-8.html">
            
                    
                    使用 QEMU 运行
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.10" data-path="../../lab-0/guide/part-9.html">
            
                <a href="../../lab-0/guide/part-9.html">
            
                    
                    接口封装和代码整理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.11" data-path="../../lab-0/guide/summary.html">
            
                <a href="../../lab-0/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.2" >
            
                <span>
            
                    
                    实验指导一
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../../lab-1/guide/intro.html">
            
                <a href="../../lab-1/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="../../lab-1/guide/part-1.html">
            
                <a href="../../lab-1/guide/part-1.html">
            
                    
                    什么是中断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="../../lab-1/guide/part-2.html">
            
                <a href="../../lab-1/guide/part-2.html">
            
                    
                    RISC-V 中的中断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="../../lab-1/guide/part-3.html">
            
                <a href="../../lab-1/guide/part-3.html">
            
                    
                    程序运行状态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="../../lab-1/guide/part-4.html">
            
                <a href="../../lab-1/guide/part-4.html">
            
                    
                    状态的保存与恢复
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="../../lab-1/guide/part-5.html">
            
                <a href="../../lab-1/guide/part-5.html">
            
                    
                    进入中断处理流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.7" data-path="../../lab-1/guide/part-6.html">
            
                <a href="../../lab-1/guide/part-6.html">
            
                    
                    时钟中断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.8" data-path="../../lab-1/guide/summary.html">
            
                <a href="../../lab-1/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" >
            
                <span>
            
                    
                    实验指导二
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="intro.html">
            
                <a href="intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.3.2" data-path="part-1.html">
            
                <a href="part-1.html">
            
                    
                    动态内存分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="part-2.html">
            
                <a href="part-2.html">
            
                    
                    物理内存探测
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.4" data-path="part-3.html">
            
                <a href="part-3.html">
            
                    
                    物理内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.5" data-path="summary.html">
            
                <a href="summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" >
            
                <span>
            
                    
                    实验指导三
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="../../lab-3/guide/intro.html">
            
                <a href="../../lab-3/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="../../lab-3/guide/part-1.html">
            
                <a href="../../lab-3/guide/part-1.html">
            
                    
                    从虚拟地址到物理地址
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="../../lab-3/guide/part-2.html">
            
                <a href="../../lab-3/guide/part-2.html">
            
                    
                    修改内核
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="../../lab-3/guide/part-3.html">
            
                <a href="../../lab-3/guide/part-3.html">
            
                    
                    实现页表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="../../lab-3/guide/part-4.html">
            
                <a href="../../lab-3/guide/part-4.html">
            
                    
                    实现内核重映射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="../../lab-3/guide/part-5.html">
            
                <a href="../../lab-3/guide/part-5.html">
            
                    
                    页面置换*
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.7" data-path="../../lab-3/guide/summary.html">
            
                <a href="../../lab-3/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" >
            
                <span>
            
                    
                    实验指导四
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="../../lab-4/guide/intro.html">
            
                <a href="../../lab-4/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.2" data-path="../../lab-4/guide/part-1.html">
            
                <a href="../../lab-4/guide/part-1.html">
            
                    
                    线程和进程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.3" data-path="../../lab-4/guide/part-2.html">
            
                <a href="../../lab-4/guide/part-2.html">
            
                    
                    线程的创建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.4" data-path="../../lab-4/guide/part-3.html">
            
                <a href="../../lab-4/guide/part-3.html">
            
                    
                    线程的切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.5" data-path="../../lab-4/guide/part-4.html">
            
                <a href="../../lab-4/guide/part-4.html">
            
                    
                    线程的结束
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.6" data-path="../../lab-4/guide/part-5.html">
            
                <a href="../../lab-4/guide/part-5.html">
            
                    
                    内核栈
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.7" data-path="../../lab-4/guide/part-6.html">
            
                <a href="../../lab-4/guide/part-6.html">
            
                    
                    线程调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.8" data-path="../../lab-4/guide/summary.html">
            
                <a href="../../lab-4/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" >
            
                <span>
            
                    
                    实验指导五
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="../../lab-5/guide/intro.html">
            
                <a href="../../lab-5/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.2" data-path="../../lab-5/guide/part-1.html">
            
                <a href="../../lab-5/guide/part-1.html">
            
                    
                    设备树
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.3" data-path="../../lab-5/guide/part-2.html">
            
                <a href="../../lab-5/guide/part-2.html">
            
                    
                    virtio
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.4" data-path="../../lab-5/guide/part-3.html">
            
                <a href="../../lab-5/guide/part-3.html">
            
                    
                    驱动和块设备驱动
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.5" data-path="../../lab-5/guide/part-4.html">
            
                <a href="../../lab-5/guide/part-4.html">
            
                    
                    文件系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.6" data-path="../../lab-5/guide/summary.html">
            
                <a href="../../lab-5/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" >
            
                <span>
            
                    
                    实验指导六
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="../../lab-6/guide/intro.html">
            
                <a href="../../lab-6/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.2" data-path="../../lab-6/guide/part-1.html">
            
                <a href="../../lab-6/guide/part-1.html">
            
                    
                    构建用户程序框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.3" data-path="../../lab-6/guide/part-2.html">
            
                <a href="../../lab-6/guide/part-2.html">
            
                    
                    打包为磁盘镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.4" data-path="../../lab-6/guide/part-3.html">
            
                <a href="../../lab-6/guide/part-3.html">
            
                    
                    解析 ELF 文件并创建线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.5" data-path="../../lab-6/guide/part-4.html">
            
                <a href="../../lab-6/guide/part-4.html">
            
                    
                    实现系统调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.6" data-path="../../lab-6/guide/part-5.html">
            
                <a href="../../lab-6/guide/part-5.html">
            
                    
                    处理文件描述符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.7" data-path="../../lab-6/guide/part-6.html">
            
                <a href="../../lab-6/guide/part-6.html">
            
                    
                    条件变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.8" data-path="../../lab-6/guide/summary.html">
            
                <a href="../../lab-6/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">实验题</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../lab-1/practice.html">
            
                <a href="../../lab-1/practice.html">
            
                    
                    实验一：中断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../practice.html">
            
                <a href="../practice.html">
            
                    
                    实验二：内存分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../../lab-3/practice.html">
            
                <a href="../../lab-3/practice.html">
            
                    
                    实验三：虚实地址转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../../lab-4/practice-1.html">
            
                <a href="../../lab-4/practice-1.html">
            
                    
                    实验四（上）：线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../../lab-4/practice-2.html">
            
                <a href="../../lab-4/practice-2.html">
            
                    
                    实验四（下）：线程调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../../lab-6/practice.html">
            
                <a href="../../lab-6/practice.html">
            
                    
                    实验六：系统调用
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">开发笔记</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../../format/partition.html">
            
                <a href="../../format/partition.html">
            
                    
                    文档代码划分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../../format/doc.html">
            
                <a href="../../format/doc.html">
            
                    
                    文档格式规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../../format/code.html">
            
                <a href="../../format/code.html">
            
                    
                    代码格式规范
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../.." >动态内存分配</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;">&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;</h2>
<p>&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x5728; C/C++ &#x8BED;&#x8A00;&#x7B49;&#x4E2D;&#x4F7F;&#x7528;&#x8FC7; <code>malloc/free</code> &#x7B49;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x65B9;&#x6CD5;&#xFF0C;&#x4E0E;&#x5728;&#x7F16;&#x8BD1;&#x671F;&#x5C31;&#x5DF2;&#x5B8C;&#x6210;&#x7684;&#x9759;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x76F8;&#x6BD4;&#xFF0C;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#x65F6;&#x72B6;&#x6001;&#x4FEE;&#x6539;&#x5185;&#x5B58;&#x7533;&#x8BF7;&#x7684;&#x65F6;&#x673A;&#x53CA;&#x5927;&#x5C0F;&#xFF0C;&#x663E;&#x5F97;&#x66F4;&#x4E3A;&#x7075;&#x6D3B;&#xFF0C;&#x4F46;&#x662F;&#x8FD9;&#x662F;&#x9700;&#x8981;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x7684;&#x652F;&#x6301;&#x7684;&#xFF0C;&#x540C;&#x65F6;&#x4E5F;&#x4F1A;&#x5E26;&#x6765;&#x4E00;&#x4E9B;&#x5F00;&#x9500;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x7684;&#x5185;&#x6838;&#x4E2D;&#x4E5F;&#x9700;&#x8981;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x3002;&#x5178;&#x578B;&#x7684;&#x5E94;&#x7528;&#x573A;&#x666F;&#x6709;&#xFF1A;</p>
<ul>
<li><code>Box&lt;T&gt;</code> &#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x5B83;&#x548C; <code>malloc</code> &#x6709;&#x7740;&#x76F8;&#x540C;&#x7684;&#x529F;&#x80FD;&#xFF1B;</li>
<li>&#x5F15;&#x7528;&#x8BA1;&#x6570; <code>Rc&lt;T&gt;</code>&#xFF0C;&#x539F;&#x5B50;&#x5F15;&#x7528;&#x8BA1;&#x6570; <code>Arc&lt;T&gt;</code>&#xFF0C;&#x4E3B;&#x8981;&#x7528;&#x4E8E;&#x5728;&#x5F15;&#x7528;&#x8BA1;&#x6570;&#x6E05;&#x96F6;&#xFF0C;&#x5373;&#x67D0;&#x5BF9;&#x8C61;&#x4E0D;&#x518D;&#x88AB;&#x5F15;&#x7528;&#x65F6;&#xFF0C;&#x5BF9;&#x8BE5;&#x5BF9;&#x8C61;&#x8FDB;&#x884C;&#x81EA;&#x52A8;&#x56DE;&#x6536;&#xFF1B;</li>
<li>&#x4E00;&#x4E9B; Rust std &#x6807;&#x51C6;&#x5E93;&#x4E2D;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#xFF0C;&#x5982; <code>Vec</code> &#x548C; <code>HashMap</code> &#x7B49;&#x3002;</li>
</ul>
<p>&#x6211;&#x4EEC;&#x7F16;&#x5199;&#x7684;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x4F7F;&#x7528; Rust std &#x6807;&#x51C6;&#x5E93;&#x63D0;&#x4F9B;&#x7684;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x529F;&#x80FD;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x4E9B;&#x529F;&#x80FD;&#x9700;&#x8981;&#x5E95;&#x5C42;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x7684;&#x652F;&#x6301;&#xFF0C;&#x8FD9;&#x5C31;&#x5F62;&#x6210;&#x4E86;&#x5FAA;&#x73AF;&#x4F9D;&#x8D56;&#x7684;&#x77DB;&#x76FE;&#x4E86;&#x3002;&#x4E3A;&#x4E86;&#x5728;&#x6211;&#x4EEC;&#x7684;&#x5185;&#x6838;&#x4E2D;&#x652F;&#x6301;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#xFF0C;&#x5728; Rust &#x8BED;&#x8A00;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5B9E;&#x73B0; <code>Trait GlobalAlloc</code>&#xFF0C;&#x5C06;&#x8FD9;&#x4E2A;&#x7C7B;&#x5B9E;&#x4F8B;&#x5316;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;&#x8BED;&#x4E49;&#x9879; <code>#[global_allocator]</code> &#x8FDB;&#x884C;&#x6807;&#x8BB0;&#x3002;&#x8FD9;&#x6837;&#x7684;&#x8BDD;&#xFF0C;&#x7F16;&#x8BD1;&#x5668;&#x5C31;&#x4F1A;&#x77E5;&#x9053;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x7684;&#x5185;&#x5B58;&#x5206;&#x914D;&#x51FD;&#x6570;&#x8FDB;&#x884C;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x3002;</p>
<p>&#x4E3A;&#x4E86;&#x5B9E;&#x73B0; <code>Trait GlobalAlloc</code>&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x652F;&#x6301;&#x8FD9;&#x4E48;&#x4E24;&#x4E2A;&#x51FD;&#x6570;&#xFF1A;</p>
<pre><code class="lang-rust"><span class="hljs-keyword">unsafe</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">alloc</span></span>(&amp;<span class="hljs-keyword">self</span>, layout: Layout) -&gt; *<span class="hljs-keyword">mut</span> <span class="hljs-keyword">u8</span>;
<span class="hljs-keyword">unsafe</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">dealloc</span></span>(&amp;<span class="hljs-keyword">self</span>, ptr: *<span class="hljs-keyword">mut</span> <span class="hljs-keyword">u8</span>, layout: Layout);
</code></pre>
<p>&#x53EF;&#x89C1;&#x6211;&#x4EEC;&#x8981;&#x5206;&#x914D;/&#x56DE;&#x6536;&#x4E00;&#x5757;&#x865A;&#x62DF;&#x5185;&#x5B58;&#x3002;</p>
<p>&#x90A3;&#x4E48;&#x8FD9;&#x91CC;&#x9762;&#x7684; <code>Layout</code> &#x53C8;&#x662F;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;&#x4ECE;&#x6587;&#x6863;&#x4E2D;&#x53EF;&#x4EE5;&#x627E;&#x5230;&#xFF0C;&#x5B83;&#x6709;&#x4E24;&#x4E2A;&#x5B57;&#x6BB5;&#xFF1A;<code>size</code> &#x8868;&#x793A;&#x8981;&#x5206;&#x914D;&#x7684;&#x5B57;&#x8282;&#x6570;&#xFF0C;<code>align</code> &#x5219;&#x8868;&#x793A;&#x5206;&#x914D;&#x7684;&#x865A;&#x62DF;&#x5730;&#x5740;&#x7684;&#x6700;&#x5C0F;&#x5BF9;&#x9F50;&#x8981;&#x6C42;&#xFF0C;&#x5373;&#x5206;&#x914D;&#x7684;&#x5730;&#x5740;&#x8981;&#x6C42;&#x662F; <code>align</code> &#x7684;&#x500D;&#x6570;&#x3002;&#x8FD9;&#x91CC;&#x7684; <code>align</code> &#x5FC5;&#x987B;&#x662F; 2 &#x7684;&#x5E42;&#x6B21;&#x3002;</p>
<p>&#x4E5F;&#x5C31;&#x8868;&#x793A;&#xFF0C;&#x6211;&#x4EEC;&#x7684;&#x9700;&#x6C42;&#x662F;&#x5206;&#x914D;&#x4E00;&#x5757;&#x8FDE;&#x7EED;&#x7684;&#x3001;&#x5927;&#x5C0F;&#x81F3;&#x5C11;&#x4E3A; <code>size</code> &#x5B57;&#x8282;&#x7684;&#x865A;&#x62DF;&#x5185;&#x5B58;&#xFF0C;&#x4E14;&#x5BF9;&#x9F50;&#x8981;&#x6C42;&#x4E3A; <code>align</code> &#x3002;</p>
<h3 id="&#x8FDE;&#x7EED;&#x5185;&#x5B58;&#x5206;&#x914D;&#x7B97;&#x6CD5;">&#x8FDE;&#x7EED;&#x5185;&#x5B58;&#x5206;&#x914D;&#x7B97;&#x6CD5;</h3>
<p>&#x5047;&#x8BBE;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x6709;&#x4E00;&#x6574;&#x5757;&#x865A;&#x62DF;&#x5185;&#x5B58;&#x7528;&#x6765;&#x5206;&#x914D;&#xFF0C;&#x90A3;&#x4E48;&#x5982;&#x4F55;&#x8FDB;&#x884C;&#x5206;&#x914D;&#x5462;&#xFF1F;</p>
<p>&#x6211;&#x4EEC;&#x53EF;&#x80FD;&#x4F1A;&#x60F3;&#x5230;&#x4E00;&#x4E9B;&#x7B80;&#x5355;&#x7C97;&#x66B4;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x6BD4;&#x5982;&#x5BF9;&#x4E8E;&#x4E00;&#x4E2A;&#x5206;&#x914D;&#x4EFB;&#x52A1;&#xFF0C;&#x8D2A;&#x5FC3;&#x5730;&#x5C06;&#x5176;&#x5206;&#x914D;&#x5230;&#x53EF;&#x884C;&#x7684;&#x6700;&#x5C0F;&#x5730;&#x5740;&#x53BB;&#x3002;&#x8FD9;&#x6837;&#x4E00;&#x76F4;&#x5206;&#x914D;&#x4E0B;&#x53BB;&#x7684;&#x8BDD;&#xFF0C;&#x6211;&#x4EEC;&#x5206;&#x914D;&#x51FA;&#x53BB;&#x7684;&#x5185;&#x5B58;&#x90FD;&#x662F;&#x8FDE;&#x7EED;&#x7684;&#xFF0C;&#x770B;&#x4E0A;&#x53BB;&#x5F88;&#x5408;&#x7406;&#x7684;&#x5229;&#x7528;&#x4E86;&#x5185;&#x5B58;&#x3002;</p>
<p>&#x4F46;&#x662F;&#x4E00;&#x65E6;&#x6D89;&#x53CA;&#x5230;&#x56DE;&#x6536;&#x7684;&#x8BDD;&#xFF0C;&#x8BBE;&#x60F3;&#x6211;&#x4EEC;&#x5728;&#x8FDE;&#x7EED;&#x5206;&#x914D;&#x51FA;&#x53BB;&#x7684;&#x5F88;&#x591A;&#x5757;&#x5185;&#x5B58;&#x4E2D;&#x95F4;&#x7A81;&#x7136;&#x56DE;&#x6536;&#x6389;&#x4E00;&#x5757;&#xFF0C;&#x5B83;&#x867D;&#x7136;&#x662F;&#x53EF;&#x7528;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x7531;&#x4E8E;&#x4E0A;&#x4E0B;&#x4E24;&#x8FB9;&#x90FD;&#x5DF2;&#x7ECF;&#x88AB;&#x5206;&#x914D;&#x51FA;&#x53BB;&#xFF0C;&#x5B83;&#x5C31;&#x53EA;&#x6709;&#x8FD9;&#x4E48;&#x5927;&#x800C;&#x4E0D;&#x80FD;&#x518D;&#x88AB;&#x62D3;&#x5C55;&#x4E86;&#xFF0C;&#x8FD9;&#x79CD;&#x53EF;&#x7528;&#x7684;&#x5185;&#x5B58;&#x6211;&#x4EEC;&#x79F0;&#x4E4B;&#x4E3A;<strong>&#x5916;&#x788E;&#x7247;</strong>&#x3002;</p>
<p>&#x968F;&#x7740;&#x4E0D;&#x65AD;&#x56DE;&#x6536;&#x4F1A;&#x4EA7;&#x751F;&#x8D8A;&#x6765;&#x8D8A;&#x591A;&#x7684;&#x788E;&#x7247;&#xFF0C;&#x67D0;&#x4E2A;&#x65F6;&#x523B;&#x6211;&#x4EEC;&#x53EF;&#x80FD;&#x4F1A;&#x53D1;&#x73B0;&#xFF0C;&#x9700;&#x8981;&#x5206;&#x914D;&#x4E00;&#x5757;&#x8F83;&#x5927;&#x7684;&#x5185;&#x5B58;&#xFF0C;&#x51E0;&#x4E2A;&#x788E;&#x7247;&#x52A0;&#x8D77;&#x6765;&#x5927;&#x5C0F;&#x662F;&#x8DB3;&#x591F;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x5355;&#x4E2A;&#x788E;&#x7247;&#x662F;&#x4E0D;&#x591F;&#x7684;&#x3002;&#x6211;&#x4EEC;&#x4F1A;&#x60F3;&#x5230;&#x901A;&#x8FC7;<strong>&#x788E;&#x7247;&#x6574;&#x7406;</strong>&#x5C06;&#x51E0;&#x4E2A;&#x788E;&#x7247;&#x5408;&#x5E76;&#x8D77;&#x6765;&#x3002;&#x4F46;&#x662F;&#x8FD9;&#x4E2A;&#x8FC7;&#x7A0B;&#x7684;&#x5F00;&#x9500;&#x6781;&#x5927;&#x3002;</p>
<p>&#x5728;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x8BFE;&#x7A0B;&#x4E0A;&#xFF0C;&#x6211;&#x4EEC;&#x4E86;&#x89E3;&#x5230;&#x8FD8;&#x6709;&#x82E5;&#x5E72;&#x66F4;&#x6709;&#x6548;&#x7684;&#x5185;&#x5B58;&#x5206;&#x914D;&#x7B97;&#x6CD5;&#xFF0C;&#x5305;&#x62EC;&#x4F19;&#x4F34;&#x7CFB;&#x7EDF;&#xFF08;Buddy System&#xFF09;&#x548C; SLAB &#x5206;&#x914D;&#x5668;&#x7B49;&#x7B97;&#x6CD5;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x8FD9;&#x91CC;&#x4F7F;&#x7528; Buddy System &#x6765;&#x5B9E;&#x73B0;&#x8FD9;&#x4EF6;&#x4E8B;&#x60C5;&#x3002;</p>
<h3 id="&#x652F;&#x6301;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;">&#x652F;&#x6301;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;</h3>
<p>&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x91CD;&#x590D;&#x9020;&#x8F6E;&#x5B50;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5F00;&#x4E00;&#x4E2A;&#x9759;&#x6001;&#x7684; 8M &#x6570;&#x7EC4;&#x4F5C;&#x4E3A;&#x5806;&#x7684;&#x7A7A;&#x95F4;&#xFF0C;&#x7136;&#x540E;&#x8C03;&#x7528; <a href="https://github.com/jiegec/" target="_blank">@jiege</a> &#x5F00;&#x53D1;&#x7684; <a href="https://github.com/rcore-os/buddy_system_allocator" target="_blank">Buddy System Allocator</a>&#x3002;</p>
<p></p><p class="code-label">os/src/memory/config.rs</p><p></p>
<pre><code class="lang-rust"><span class="hljs-comment">/// &#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x52A8;&#x6001;&#x5206;&#x914D;&#x5185;&#x5B58;&#x6240;&#x7528;&#x7684;&#x5806;&#x5927;&#x5C0F;&#xFF08;8M&#xFF09;</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">const</span> KERNEL_HEAP_SIZE: usize = <span class="hljs-number">0x80_0000</span>;
</code></pre>
<p></p><p class="code-label">os/src/memory/heap.rs</p><p></p>
<pre><code class="lang-rust"><span class="hljs-comment">/// &#x8FDB;&#x884C;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x6240;&#x7528;&#x7684;&#x5806;&#x7A7A;&#x95F4;</span>
<span class="hljs-comment">/// </span>
<span class="hljs-comment">/// &#x5927;&#x5C0F;&#x4E3A; [`KERNEL_HEAP_SIZE`]  </span>
<span class="hljs-comment">/// &#x8FD9;&#x6BB5;&#x7A7A;&#x95F4;&#x7F16;&#x8BD1;&#x540E;&#x4F1A;&#x88AB;&#x653E;&#x5728;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x7684; bss &#x6BB5;</span>
<span class="hljs-keyword">static</span> <span class="hljs-keyword">mut</span> HEAP_SPACE: [<span class="hljs-keyword">u8</span>; KERNEL_HEAP_SIZE] = [<span class="hljs-number">0</span>; KERNEL_HEAP_SIZE];

<span class="hljs-comment">/// &#x5806;&#xFF0C;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x5668;</span>
<span class="hljs-comment">/// </span>
<span class="hljs-comment">/// ### `#[global_allocator]`</span>
<span class="hljs-comment">/// [`LockedHeap`] &#x5B9E;&#x73B0;&#x4E86; [`alloc::alloc::GlobalAlloc`] trait&#xFF0C;</span>
<span class="hljs-comment">/// &#x53EF;&#x4EE5;&#x4E3A;&#x5168;&#x5C40;&#x9700;&#x8981;&#x7528;&#x5230;&#x5806;&#x7684;&#x5730;&#x65B9;&#x5206;&#x914D;&#x7A7A;&#x95F4;&#x3002;&#x4F8B;&#x5982; `Box` `Arc` &#x7B49;</span>
<span class="hljs-meta">#[global_allocator]</span>
<span class="hljs-keyword">static</span> HEAP: LockedHeap = LockedHeap::empty();

<span class="hljs-comment">/// &#x521D;&#x59CB;&#x5316;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x8FD0;&#x884C;&#x65F6;&#x5806;&#x7A7A;&#x95F4;</span>
<span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">init</span></span>() {
    <span class="hljs-comment">// &#x544A;&#x8BC9;&#x5206;&#x914D;&#x5668;&#x4F7F;&#x7528;&#x8FD9;&#x4E00;&#x6BB5;&#x9884;&#x7559;&#x7684;&#x7A7A;&#x95F4;&#x4F5C;&#x4E3A;&#x5806;</span>
    <span class="hljs-keyword">unsafe</span> {
        HEAP.lock().init(
            HEAP_SPACE.as_ptr() <span class="hljs-keyword">as</span> usize, KERNEL_HEAP_SIZE
        )
    }
}

<span class="hljs-comment">/// &#x7A7A;&#x95F4;&#x5206;&#x914D;&#x9519;&#x8BEF;&#x7684;&#x56DE;&#x8C03;&#xFF0C;&#x76F4;&#x63A5; panic &#x9000;&#x51FA;</span>
<span class="hljs-meta">#[alloc_error_handler]</span>
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">alloc_error_handler</span></span>(_: alloc::alloc::Layout) -&gt; ! {
    <span class="hljs-built_in">panic!</span>(<span class="hljs-string">&quot;alloc error&quot;</span>)
}
</code></pre>
<p>&#x540C;&#x65F6;&#x8FD8;&#x6709;&#x4E00;&#x4E9B;&#x6A21;&#x5757;&#x8C03;&#x7528;&#x7B49;&#x7EC6;&#x8282;&#x4EE3;&#x7801;&#xFF0C;&#x8FD9;&#x91CC;&#x4E0D;&#x518D;&#x8D34;&#x51FA;&#xFF0C;&#x8BF7;&#x53C2;&#x8003;&#x5B8C;&#x6210;&#x672C;&#x7AE0;&#x540E;&#x7684;&#x4ED3;&#x5E93;&#x4E2D;&#x7684;&#x4EE3;&#x7801;&#x3002;</p>
<div class="click_reveal"><span> Click to show </span><div><blockquote>
<p>&#x63D0;&#x793A;&#xFF1A;</p>
<ol>
<li>&#x5728; <code>os/Cargo.toml</code> &#x4E2D;&#x6DFB;&#x52A0;&#x76F8;&#x5173;&#x7684;&#x4F9D;&#x8D56;&#xFF1B;</li>
<li>&#x5728; <code>os/main.rs</code>  &#x4E2D;&#x6DFB;&#x52A0;&#x5BF9; Rust &#x65B0;&#x7279;&#x6027; <code>alloc_error_handler</code> &#x7684;&#x5F15;&#x7528;&#x3002;</li>
</ol>
</blockquote>
</div></div>


<h3 id="&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x6D4B;&#x8BD5;">&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x6D4B;&#x8BD5;</h3>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x6765;&#x6D4B;&#x8BD5;&#x4E00;&#x4E0B;&#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x662F;&#x5426;&#x6709;&#x6548;&#xFF0C;&#x5206;&#x914D;&#x4E00;&#x4E2A;&#x52A8;&#x6001;&#x6570;&#x7EC4;&#xFF1A;</p>
<p></p><p class="code-label">os/src/main.rs</p><p></p>
<pre><code class="lang-rust"><span class="hljs-comment">/// Rust &#x7684;&#x5165;&#x53E3;&#x51FD;&#x6570;</span>
<span class="hljs-comment">///</span>
<span class="hljs-comment">/// &#x5728; `_start` &#x4E3A;&#x6211;&#x4EEC;&#x8FDB;&#x884C;&#x4E86;&#x4E00;&#x7CFB;&#x5217;&#x51C6;&#x5907;&#x4E4B;&#x540E;&#xFF0C;&#x8FD9;&#x662F;&#x7B2C;&#x4E00;&#x4E2A;&#x88AB;&#x8C03;&#x7528;&#x7684; Rust &#x51FD;&#x6570;</span>
<span class="hljs-meta">#[no_mangle]</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">extern</span> <span class="hljs-string">&quot;C&quot;</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">rust_main</span></span>() -&gt; ! {
    <span class="hljs-comment">// &#x521D;&#x59CB;&#x5316;&#x5404;&#x79CD;&#x6A21;&#x5757;</span>
    interrupt::init();
    memory::init();

    <span class="hljs-comment">// &#x52A8;&#x6001;&#x5185;&#x5B58;&#x5206;&#x914D;&#x6D4B;&#x8BD5;</span>
    <span class="hljs-keyword">use</span> alloc::boxed::<span class="hljs-built_in">Box</span>;
    <span class="hljs-keyword">use</span> alloc::vec::<span class="hljs-built_in">Vec</span>;
    <span class="hljs-keyword">let</span> v = <span class="hljs-built_in">Box</span>::new(<span class="hljs-number">5</span>);
    <span class="hljs-built_in">assert_eq!</span>(*v, <span class="hljs-number">5</span>);
    core::mem::<span class="hljs-built_in">drop</span>(v);

    <span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> vec = <span class="hljs-built_in">Vec</span>::new();
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-number">0</span>..<span class="hljs-number">10000</span> {
        vec.push(i);
    }
    <span class="hljs-built_in">assert_eq!</span>(vec.len(), <span class="hljs-number">10000</span>);
    <span class="hljs-keyword">for</span> (i, value) <span class="hljs-keyword">in</span> vec.into_iter().enumerate() {
        <span class="hljs-built_in">assert_eq!</span>(value, i);
    }
    <span class="hljs-built_in">println!</span>(<span class="hljs-string">&quot;heap test passed&quot;</span>);

    <span class="hljs-built_in">panic!</span>()
}
</code></pre>
<p>&#x6700;&#x540E;&#xFF0C;&#x8FD0;&#x884C;&#x4E00;&#x4E0B;&#x4F1A;&#x770B;&#x5230; <code>heap test passed</code> &#x7C7B;&#x4F3C;&#x7684;&#x8F93;&#x51FA;&#x3002;&#x6709;&#x4E86;&#x8FD9;&#x4E2A;&#x5DE5;&#x5177;&#x4E4B;&#x540E;&#xFF0C;&#x540E;&#x9762;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E00;&#x7CFB;&#x5217;&#x8BF8;&#x5982; <code>Vec</code> &#x7B49;&#x57FA;&#x4E8E;&#x52A8;&#x6001;&#x5206;&#x914D;&#x5B9E;&#x73B0;&#x7684;&#x5E93;&#x4E2D;&#x7684;&#x7ED3;&#x6784;&#x4E86;&#x3002;</p>
<h3 id="&#x601D;&#x8003;">&#x601D;&#x8003;</h3>
<p>&#x52A8;&#x6001;&#x5206;&#x914D;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#x5728;&#x54EA;&#x4E2A;&#x8303;&#x56F4;&#x91CC;&#xFF1F;</p>
<div class="click_reveal"><span> Click to show </span><div><blockquote>
<p>&#x5728; .bss &#x6BB5;&#x4E2D;&#xFF0C;&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x7528;&#x6765;&#x5B58;&#x653E;&#x52A8;&#x6001;&#x5206;&#x914D;&#x7684;&#x8FD9;&#x6BB5;&#x662F;&#x4E00;&#x4E2A;&#x9759;&#x6001;&#x7684;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;&#x7684;&#x6570;&#x7EC4;&#xFF0C;&#x7B97;&#x662F;&#x5185;&#x6838;&#x4EE3;&#x7801;&#x7684;&#x4E00;&#x90E8;&#x5206;&#x3002;</p>
</blockquote>
</div></div>


<p><div id="page-footer" class="localized-footer"><hr><p><link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css"></p>
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
    var gitalk = new Gitalk({
        clientID: "5084c46751a4b2f7cd4d",
        clientSecret: "3904f62d33aef24f19480fedc836a48b31d532e9",
        repo: "rCore-Tutorial-deploy",
        owner: "rcore-os",
        admin: [
            "chyyuu",
            "wangrunji0408",
            "xy-plus",
            "wyfcyx",
            "LyricZhao",
            "Tuyixiang"
        ],
        id: location.pathname.replace('/rCore-Tutorial-deploy', '').replace('.html', ''),
        distractionFreeMode: false
    });
    gitalk.render("gitalk-container");
</script></div></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="intro.html" class="navigation navigation-prev " aria-label="Previous page: 摘要">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="part-2.html" class="navigation navigation-next " aria-label="Next page: 物理内存探测">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"动态内存分配","level":"3.3.2","depth":2,"next":{"title":"物理内存探测","level":"3.3.3","depth":2,"path":"docs/lab-2/guide/part-2.md","ref":"docs/lab-2/guide/part-2.md","articles":[]},"previous":{"title":"摘要","level":"3.3.1","depth":2,"path":"docs/lab-2/guide/intro.md","ref":"docs/lab-2/guide/intro.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["hide-element","chapter-fold","katex","alerts","emphasize","mermaid-gb3","codeblock-label","code","search-pro","click-reveal","expandable-chapters-interactive","localized-footer"],"pluginsConfig":{"chapter-fold":{},"emphasize":{},"codeblock-label":{},"search-pro":{},"search":{},"localized-footer":{"filename":"gitalk.html","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"hide-element":{},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":1},"click-reveal":{},"highlight":{},"mermaid-gb3":{},"expandable-chapters-interactive":{},"alerts":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docs/lab-2/guide/part-1.md","mtime":"2020-10-01T11:39:40.511Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-10-01T11:40:38.595Z"},"basePath":"../../..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../../../gitbook/gitbook.js"></script>
    <script src="../../../gitbook/theme.js"></script>
    
        
        <script src="../../../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-click-reveal/click_reveal.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

